package org.lalib.controller.service;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.lalib.acquire.IControllerService;
import org.lalib.entity.object.EUserGroup;
import org.lalib.mediator.MUserGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "cUserGroupService")
public class CUserGroupService implements IControllerService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Autowired
	private MUserGroup mUserGroup;

	public void insert(EUserGroup eUserGroup) {
		mUserGroup.insert(eUserGroup);
	}

	public void update(EUserGroup eUserGroup) {
		mUserGroup.update(eUserGroup);
	}

	public void remove(EUserGroup eUserGroup) {
		mUserGroup.remove(eUserGroup);
	}

	public List<EUserGroup> getAllUserGroups() {
		return getUserGroupImpl().getAllUserGroups();
	}

	public List<SelectItem> getSelectItemListForUserGroup(List<EUserGroup> userGroups) {
		List<SelectItem> selectItemList = new ArrayList<>();
		for (EUserGroup userGroup : userGroups)
			selectItemList.add(new SelectItem(userGroup.getId(), userGroup.getName()));
		return selectItemList;
	}

	public MUserGroup getUserGroupImpl() {
		return mUserGroup;
	}

	public void setUserGroupImpl(MUserGroup userGroupImpl) {
		this.mUserGroup = userGroupImpl;
	}

}